package com.news.model;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.List;

public class NewsServletAndroid extends HttpServlet {
    public void doGet(HttpServletRequest rq, HttpServletResponse rp) 
    				throws ServletException, IOException{
    	NewsDAO newsDAO = new NewsDAO();
    	List<NewsVO> newsList = newsDAO.getAll();
    	//
    	NewsJsonHandler newsJsonHandler = new NewsJsonHandler();
    	String newsJsonStr = newsJsonHandler.toJSONArray(newsList).toString();
  
        rp.setContentType("text/html; charset=utf-8");
        PrintWriter out = rp.getWriter();
        out.println(newsJsonStr); 
        out.close();
    }
    public void doPost(HttpServletRequest rq, HttpServletResponse rp) 
    				throws ServletException, IOException{
        doGet(rq, rp); 
    }
}